#ifndef NET_RUNNER_H
#define NET_RUNNER_H

#include <QtCore/QHash>
#include <QtCore/QPointer>

namespace wfnet
{
class WfNet;
class NetRunnable;

class NetRunner : public QObject
{
    Q_OBJECT
public:
    static NetRunner* getInstance();
    static void destroy();

    void runNet(WfNet* net, int repetitions);
    void pauseNet(WfNet* net);
    void stopNet(WfNet* net);

    QPointer<NetRunnable> getRunnable(WfNet* net) const;

private:
    NetRunner();
    ~NetRunner();

private slots:
    void onFinished();
    void onTerminated();

private:
    QHash<WfNet*, NetRunnable* > m_runningNets;
    bool m_terminateRequest;
};

} // namespace wfnet

#endif
